﻿@model FYSJcrm.Core.Model.PermManage.ManagerEntity
@{
    ViewBag.Title = "修改密码";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<style type="text/css">
    body {
        background: #fff !important;
    }
</style>
<div class="wap-container">
    <div class="panel">
        <div class="panel-body">
            <form class="layui-form layui-form-pane">
                <input type="hidden" name="userId" value="@Model.Id" />
                <div class="layui-row">
                    <div class="layui-col-xs12">
                        <div class="layui-form-item">
                            <label class="layui-form-label"><span class="c-red">*</span>管理员</label>
                            <div class="layui-input-block">
                                <input type="text" readonly="readonly" value="@Model.UserName" autocomplete="off" class="layui-input" lay-verify="required" />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-row">
                    <div class="layui-col-xs12">
                        <div class="layui-form-item">
                            <label class="layui-form-label"><span class="c-red">*</span>旧密码</label>
                            <div class="layui-input-block">
                                <input type="password" name="oldPassword" placeholder="请输入旧密码" autocomplete="off" class="layui-input" lay-verify="required" />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-row">
                    <div class="layui-col-xs12">
                        <div class="layui-form-item">
                            <label class="layui-form-label"><span class="c-red">*</span>新密码</label>
                            <div class="layui-input-block">
                                <input type="password" name="newPassword" placeholder="请输入新密码" autocomplete="off" class="layui-input" lay-verify="required" />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-row">
                    <div class="layui-col-xs12">
                        <div class="layui-form-item">
                            <label class="layui-form-label"><span class="c-red">*</span>确认密码</label>
                            <div class="layui-input-block">
                                <input type="password" name="newPassword2" placeholder="请再输入一遍新密码" autocomplete="off" class="layui-input" lay-verify="required" />
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-row">
                    <div class="layui-col-xs12" style="text-align:center;">
                        <button type="submit" class="layui-btn" lay-submit="" lay-filter="adminForm">提交保存</button>
                        <button type="button" class="layui-btn layui-btn-primary" onclick="layer_close()">取消保存</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

@section FooterScript{
    <script type="text/javascript">
        layui.use(['form'], function () {
            var form = layui.form;

            form.on('submit(adminForm)', function (data) {
                let index = "";
                $.ajax({
                    url: '/PermManage/AdminUser/ChangePassword',
                    type: 'POST',
                    dataType: 'json',
                    data: data.field,
                    beforeSend: function () {
                        index = layer.load(1, { shade: [0.3, '#000'] });
                    },
                    success: function (res) {
                        if (res.code === 200) {
                            layer.msg(res.data, { icon: 1, time: 1000 }, function () {
                                parent.location.reload();
                            });
                        } else {
                            layer.msg(res.errorMsg, { icon: 2, time: 2000 });
                        }
                    },
                    error: function () {
                        layer.msg('网络错误', { icon: 2, time: 2000 });
                    },
                    complete: function () {
                        layer.close(index);
                    }
                });

                return false;
            })
        });
    </script>
} 